function ParamsUtil() {}

ParamsUtil.excludeNull = function(params, isPrint) {
    let data = {};
    Object.keys(params).forEach((key) => {
        if (params[key] !== "" && params[key] != null) {
            if (isPrint) {
                console.log("paramIn", key, params[key]);
            }
            data[key] = params[key];
        } else {
            if (isPrint) {
                console.log("paramOut", key, params[key]);
            }
        }
    });
    return data;
};

ParamsUtil.convertToFormData = function(params, isPrint) {
    let formData = new FormData();
    Object.keys(params).forEach((key) => {
        if (params[key] !== "" && params[key] != null) {
            if (isPrint) {
                console.log("paramIn", key, params[key]);
            }
            formData.append(key, params[key]);
        } else {
            if (isPrint) {
                console.log("paramOut", key, params[key]);
            }
        }
    });
    return formData;
};

ParamsUtil.ToOneDimensionalArray = function(params) {
    // console.log('params',params)
    let param1 = []
    params.forEach(item => {
        // console.log('ToOneDimensionalArray',typeof item)
        if (typeof item === "object") {
            item.forEach(item1 => {
                param1.push(item1)
            })
        }
    })
    return param1
}

ParamsUtil.toArray = function (params) {
    params.forEach(item => {
            let param1 = []
            item.answers.forEach(item1 => {
                param1.push(item1.value)
            })
            item.answers = param1
    })
    return params
}
export default ParamsUtil;
